/*
 * @Author: LVGRAPE
 * @LastEditors: LVGRAPE
 */
/***
 * @Author: LVGRAPE
 * @Date: 2022-07-27 14:01:23
 * @LastEditTime: 2023-11-08 18:00:40
 * @LastEditors: LVGRAPE
 * @Description:
 * @FilePath: \ZINO_MCU_SOURCE\ZINO_SRC\ZINO_FC\sensors\acc_gyro\acc_gyro.h
 * @可以输入预定的版权声明、个性签名、空行等
 */

#ifndef __ACC_GYRO_H_
#define __ACC_GYRO_H_
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

#include <stdint.h>
#include <stdbool.h>
#include "axis.h"

typedef struct
{
    Axis3float accZero; //校准后的零点
    Axis3float gyroZero;//校准后的零点
    Axis3float gyroCaliSum;//校准时的和
    Axis3float accCaliSum;//校准时的和
    Axis3float acc_raw;//原始数据-度
    Axis3float gyro_raw;//原始数据-g
    Axis3float accCalibrated;//原始数据-度
    Axis3float gyroCalibrated;//原始数据-g
    Axis3float accLpf;//原始数据-度
    Axis3float gyroLpf;//原始数据-g
    uint16_t accCalibrationSampleCount;
    uint16_t gyroCalibrationSampleCount;
    bool online;
    float temperature;
    struct acc_gyro_sensor_ops *sensor;
    struct acc_gyro_ops *ops;
}__attribute__((packed)) acc_gyro_dev_t;
struct acc_gyro_sensor_ops{
    bool (*init)(acc_gyro_dev_t *dev);
    bool (*loadNewData)(acc_gyro_dev_t *dev,float acc[3], float gyro[3]);//装载原始数据
    bool (*isOnline)(acc_gyro_dev_t *dev);
    bool (*getTemperature)(acc_gyro_dev_t *dev);
};
struct acc_gyro_ops
{
    // void (*hardware_reset)(void);
    void (*update)(acc_gyro_dev_t *dev);//加工原始数据
    void (*acc_start_calibration)(acc_gyro_dev_t *dev);
    void (*gyro_start_calibration)(acc_gyro_dev_t *dev);
    bool (*isAccCalibrated)(acc_gyro_dev_t *dev);
    bool (*isGyroCalibrated)(acc_gyro_dev_t *dev);
    uint8_t (*read)(uint8_t addr, uint8_t *buffer, uint16_t numToRead);
    uint8_t (*write)(uint8_t addr, uint8_t *buffer, uint16_t numToWrite);
};
void acc_gyro_init_dev(acc_gyro_dev_t *dev);


#ifdef __cplusplus
}
#endif // __cplusplus
#endif
